package com.example.nio.controller;

import com.example.nio.commons.OftenReply;
import com.example.nio.commons.Result;
import com.example.nio.dao.OftenReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/OftenReply")
public class OftenReplyController {
    @Autowired
    private OftenReplyMapper oftenReplyMapper;

    @RequestMapping("/getOftenReply")
    public Result getOftenReply(@RequestParam(value = "title",required = false)String title){
        return Result.ok(oftenReplyMapper.getOftenReply(title));
    }


    @PostMapping("/addOftenReply")
    public Result addOftenReply(@RequestBody OftenReply oftenReply){
        oftenReplyMapper.addOftenReply(oftenReply);
        return Result.ok("常用语添加成功");
    }
    @RequestMapping("/getOftenReplyTitle")
    public Result getOftenReplyTitle(){
        return Result.ok(oftenReplyMapper.getOftenReplyTitle());
    }
    @DeleteMapping("/deleteOftenReply")
    public Result delOftenReply(@RequestParam("id")Integer id){
        oftenReplyMapper.delOftenReply(id);
        return Result.ok("常用语删除成功");
    }
}
